package com.example.demo01.Controller.webController;

import com.alibaba.fastjson.JSON;
import com.example.demo01.Service.webService.NVWeightService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class NVWeightController {

    //自动装配
    @Autowired
    NVWeightService nvWeightService;

    /**
     * 按照护理等级获取对应的服务次数，并计算权重
     * */
    @RequestMapping("/nvweight/GET/barweightdata")
    public String getNVWeightListByNurseLevel(){ return JSON.toJSONString(nvWeightService.getNVWeightListByNurseLevel()); }

    /**
     * 按照护理等级获取对应的服务次数，并计算权重——格式化后的数据
     * */
    @RequestMapping("/nvweight/GET/barweightdata/format")
    public String getNVWeightListByNurseLevelFormat(){ return JSON.toJSONString(nvWeightService.getNVWeightListByNurseLevelFormat()); }

    /**
     * 按照护理等级获取对应的服务次数——时间限定
     * @param startTime 起始时间
     * @param endTime 终止时间
     * */
    @RequestMapping("/nvweight/GET/barweightdata/time")
    public String getNVWeightByNurseLevelTime(
            @RequestParam(value = "starttime") Long startTime,
            @RequestParam(value = "endtime") Long endTime)
    { return JSON.toJSONString(nvWeightService.getNVWeightByNurseLevelTime(startTime,endTime));}

    /**
     * 按照护理等级获取对应的服务次数——时间限定——格式化后的数据
     * @param start 起始时间
     * @param end 终止时间
     * */
    @RequestMapping("/nvweight/GET/barweightdata/time/format")
    public String getNVWeightByNurseLevelTimeFormat(
            @RequestParam(value = "starttime") Long start,
            @RequestParam(value = "endtime") Long end)
    { return  JSON.toJSONString(nvWeightService.getNVWeightByNurseLevelTimeFormat(start,end)); }

    /**
     * 按照省级划分
     * */
    @RequestMapping("/nvweight/GET/barweightdata/12")
    public String getNVWeightByProvinceCode(){ return JSON.toJSONString(nvWeightService.getNVWeightByProvinceCode());}

    /**
     * 按照省级划分——格式化的结果
     * */
    @RequestMapping("/nvweight/GET/barweightdata/12/format")
    public String getNVWeightByProvinceCodeFormat(){ return JSON.toJSONString(nvWeightService.getNVWeightByProvinceCodeFormat());}

    /**
     * 按照省级划分——时间限定
     * @param start 起始时间
     * @param end 终止时间
     * */
    @RequestMapping("/nvweight/GET/barweightdata/12/time")
    public String getNVWeightByProvinceCodeTime(@RequestParam(value = "starttime") Long start,
                                                @RequestParam(value = "endtime") Long end)
    { return JSON.toJSONString(nvWeightService.getNVWeightByProvinceCodeTime(start, end)); }

    /**
     * 按照省级划分——时间限定——格式化的结果
     * @param start 起始时间
     * @param end 终止时间
     * */
    @RequestMapping("/nvweight/GET/barweightdata/12/time/format")
    public String getNVWeightByProvinceCodeTimeFormat(@RequestParam(value = "starttime") Long start,
    @RequestParam(value = "endtime") Long end)
    { return JSON.toJSONString(nvWeightService.getNVWeightByProvinceCodeTimeFormat(start, end));}


    /**
     * 按照市区划分
     * */
    @RequestMapping("/nvweight/GET/barweightdata/34")
    public String getNVWeightByCityCode(){ return JSON.toJSONString(nvWeightService.getNVWeightByCityCode()); }

    /**
     * 按照市区划分——时间限定
     * @param start 起始时间
     * @param end 终止时间
     * */
    @RequestMapping("/nvweight/GET/barweightdata/34/time")
    public String getNVWeightByCityCodeTime(@RequestParam(value = "starttime") Long start,
                                            @RequestParam(value = "endtime") Long end)
    { return JSON.toJSONString(nvWeightService.getNVWeightByCityCodeTime(start, end));}

    /**
     * 按照市区划分——时间限定——格式化的结果
     * @param start 起始时间
     * @param end 终止时间
     * */
    @RequestMapping("/nvweight/GET/barweightdata/34/time/format")
    public String getNVWeightByCityCodeTimeFormat(@RequestParam(value = "starttime") Long start,
                                                  @RequestParam(value = "endtime") Long end)
    { return JSON.toJSONString(nvWeightService.getNVWeightByCityCodeTimeFormat(start, end)); }

    /**
     * 按照市区划分——格式化的结果
     * */
    @RequestMapping("/nvweight/GET/barweightdata/34/format")
    public String getNVWeightByCityCodeFormat(){ return JSON.toJSONString(nvWeightService.getNVWeightByCityCodeFormat());}

    /**
     * 按照县乡划分
     * */
    @RequestMapping("/nvweight/GET/barweightdata/56")
    public String getNVWeightByCountryCode(){ return JSON.toJSONString(nvWeightService.getNVWeightByCountryCodeFormat()); }

    /**
     * 按照县乡划分——时间限定——格式化的结果
     * @param start 起始时间
     * @param end 终止时间
     * */
    @RequestMapping("/nvweight/GET/barweightdata/56/time")
    public String getNVWeightByCountryCodeTimeFormat(@RequestParam(value = "starttime") Long start,
                                                     @RequestParam(value = "endtime") Long end)
    { return JSON.toJSONString(nvWeightService.getNVWeightByCountryCodeTime(start, end));}

    /**
     * 按照县乡划分——时间限定
     * @param start 起始时间
     * @param end 终止时间
     * */
    @RequestMapping("/nvweight/GET/barweightdata/56/time/format")
    public String getNVWeightByCountryCodeTime(@RequestParam(value = "starttime") Long start,
                                               @RequestParam(value = "endtime") Long end)
    { return JSON.toJSONString(nvWeightService.getNVWeightByCountryCodeTimeFormat(start, end));}

    /**
     * 按照县乡划分——格式化的结果
     * */
    @RequestMapping("/nvweight/GET/barweightdata/56/format")
    public String getNVWeightByCountryCodeFormat(){return JSON.toJSONString(nvWeightService.getNVWeightByCountryCodeFormat());}

    /**
     * 根据idNum，按月份统计报警信息及其报警次数
     * @param idnum 身份证号
     * */
    @RequestMapping("/nvweight/GET/monthlydata")
    public  String getNVWeightByIdNumUnderMonth(
            @RequestParam(value = "idnum") String idnum)
    {
        return JSON.toJSONString(nvWeightService.getNVWeightByIdNumUnderMonth(idnum));
    }
}
